package com.example.administrator.szb.fragments.fragment_forTab.home;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
import com.bigkoo.convenientbanner.listener.OnItemClickListener;
import com.example.administrator.szb.R;
import com.example.administrator.szb.activity.AllJGActivity;
import com.example.administrator.szb.activity.BGZRSearch_new;
import com.example.administrator.szb.activity.BannerActivity;
import com.example.administrator.szb.activity.FastZXActivity;
import com.example.administrator.szb.activity.HomeActivity;
import com.example.administrator.szb.activity.JGXQActivity;
import com.example.administrator.szb.activity.LoginNewActivity_two;
import com.example.administrator.szb.activity.MessageActivity;
import com.example.administrator.szb.activity.SQXMActivity;
import com.example.administrator.szb.activity.SearchActivity;
import com.example.administrator.szb.activity.SearchYWActivity_new;
import com.example.administrator.szb.activity.WecomeActivity;
import com.example.administrator.szb.activity.XZYWActivity;
import com.example.administrator.szb.activity.luyan.LuYanDeatilActivity;
import com.example.administrator.szb.activity.supei.SuPeiActivity;
import com.example.administrator.szb.activity.supei.SuPeiDeatilActivity;
import com.example.administrator.szb.activity.teseservice.TeseActivity;
import com.example.administrator.szb.activity.teseservice.TeseDeatils;
import com.example.administrator.szb.adapter.ImageViewHodler;
import com.example.administrator.szb.bean.IndexBean;
import com.example.administrator.szb.bean.TmpZxBean;
import com.example.administrator.szb.tinkerutil.SampleApplicationLike;
import com.example.administrator.szb.fragments.base.MVPBaseFragment;
import com.example.administrator.szb.fragments.fragment_forTab.home.adapter.GalleryAdapter;
import com.example.administrator.szb.fragments.fragment_forTab.home.adapter.JGadapter;
import com.example.administrator.szb.fragments.fragment_forTab.home.adapter.LuYanadapter;
import com.example.administrator.szb.fragments.fragment_forTab.home.adapter.ShopAdapter;
import com.example.administrator.szb.fragments.fragment_forTab.home.adapter.Teseadapter;
import com.example.administrator.szb.fragments.fragment_forTab.home.bean.LuYanList;
import com.example.administrator.szb.fragments.fragment_forTab.home.bean.SeriveList;
import com.example.administrator.szb.fragments.fragment_forTab.home.bean.Supeis;
import com.example.administrator.szb.fragments.fragment_forTab.home.presenter.HomePresenter;
import com.example.administrator.szb.fragments.fragment_forTab.home.view.HomeView;
import com.example.administrator.szb.util.Contants;
import com.example.administrator.szb.util.QTLog;
import com.example.administrator.szb.util.SPUtils;
import com.example.administrator.szb.util.ScreenUtils;
import com.example.administrator.szb.util.Toasts;
import com.example.administrator.szb.view.TranslucentScrollView;
import com.example.administrator.szb.view.VerticalSwipeRefreshLayout;
import com.example.administrator.szb.view.discretescrollview.DiscreteScrollView;
import com.example.administrator.szb.view.discretescrollview.InfiniteScrollAdapter;
import com.example.administrator.szb.view.discretescrollview.Orientation;
import com.example.administrator.szb.view.discretescrollview.transform.ScaleTransformer;
import com.kerchin.widget.GridItemClickListener;
import com.kerchin.widget.GridViewPager;
import com.kerchin.widget.Model;
import com.meiqia.core.callback.OnInitCallback;
import com.meiqia.meiqiasdk.util.MQConfig;
import com.meiqia.meiqiasdk.util.MQIntentBuilder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2017/9/5.
 */

public class FragmentHome extends MVPBaseFragment<HomeView,HomePresenter> implements HomeView, View.OnClickListener , TranslucentScrollView.TranslucentChangedListener{
    public static boolean isLoad = false;
    private RelativeLayout rl_content;
    private TranslucentScrollView translucentScrollView;
    private ConvenientBanner home_viewpage;
    private GridViewPager mGridViewPager;
    private ImageView bangwo;
    private TextView tv_zx_more;
    private ViewFlipper viewFlipper;
    private TextView tv_supei_more;
    private DiscreteScrollView recyclerView;
    private TextView tv_tese_more;
    private com.example.administrator.szb.view.MyListView lv_tese;
    private TextView tv_luyan_more;
    private com.example.administrator.szb.view.MyListView lv_luyan;
    private TextView tv_jg_more;
    private com.example.administrator.szb.view.MyListView lv_jigou;
    private LinearLayout bar;
    private View v_statusbar;
    private android.support.v7.widget.Toolbar toolbar8;
    private ImageView homefragment_image_search;
    private TextView bar_title;
    private ImageView homefragment_image_message;
    private LinearLayout error_ll;
    private LinearLayout bar2;
    private View v_statusbar2;
    private android.support.v7.widget.Toolbar toolbar82;
    private ImageView homefragment_image_search2;
    private ImageView homefragment_image_message2;
    private Button home_fragment_button_djcs_error;
    private VerticalSwipeRefreshLayout swiperefreshlayout;
    private IndexBean indexBeans;
    @Override
    protected HomePresenter createPresenter() {
        mPresenter=new HomePresenter(this);

        return mPresenter;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_home2,null);
    }

    @Override
    protected void initView(View view) {
        swiperefreshlayout = view.findViewById(R.id.swiperefreshlayout);
        home_fragment_button_djcs_error = view.findViewById(R.id.home_fragment_button_djcs_error);
        rl_content = (RelativeLayout) view.findViewById(R.id.rl_content);
        translucentScrollView = (TranslucentScrollView) view.findViewById(R.id.translucentScrollView);
        home_viewpage = (ConvenientBanner) view.findViewById(R.id.home_viewpage);
        mGridViewPager = view.findViewById(R.id.mGridViewPager);
        bangwo = (ImageView) view.findViewById(R.id.bangwo);
        tv_zx_more = (TextView) view.findViewById(R.id.tv_zx_more);
        viewFlipper = (ViewFlipper) view.findViewById(R.id.viewFlipper);
        viewFlipper.setOnClickListener(this);
        tv_supei_more = (TextView) view.findViewById(R.id.tv_supei_more);
        recyclerView =  view.findViewById(R.id.item_picker);
        initrecyclerView();
        /*LinearLayoutManager layoutManager = new LinearLayoutManager(context);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(layoutManager);*/
        tv_tese_more = (TextView) view.findViewById(R.id.tv_tese_more);
        lv_tese = (com.example.administrator.szb.view.MyListView) view.findViewById(R.id.lv_tese);
        tv_luyan_more = (TextView) view.findViewById(R.id.tv_luyan_more);
        lv_luyan = (com.example.administrator.szb.view.MyListView) view.findViewById(R.id.lv_luyan);
        tv_jg_more = (TextView) view.findViewById(R.id.tv_jg_more);
        lv_jigou = (com.example.administrator.szb.view.MyListView) view.findViewById(R.id.lv_jigou);
        bar = (LinearLayout) view.findViewById(R.id.bar);
        v_statusbar = (View) view.findViewById(R.id.v_statusbar);
        toolbar8 = (android.support.v7.widget.Toolbar) view.findViewById(R.id.toolbar8);
        homefragment_image_search = (ImageView) view.findViewById(R.id.homefragment_image_search);
        bar_title = (TextView) view.findViewById(R.id.bar_title);
        homefragment_image_message = (ImageView) view.findViewById(R.id.homefragment_image_message);
        error_ll = (LinearLayout) view.findViewById(R.id.error_ll);
        bar2 = (LinearLayout) view.findViewById(R.id.bar2);
        v_statusbar2 = (View) view.findViewById(R.id.v_statusbar2);
        toolbar82 = (android.support.v7.widget.Toolbar) view.findViewById(R.id.toolbar82);
        homefragment_image_search2 = (ImageView) view.findViewById(R.id.homefragment_image_search2);
        homefragment_image_message2 = (ImageView) view.findViewById(R.id.homefragment_image_message2);
        ImageView imageView27 = view.findViewById(R.id.imageView27);
        imageView27.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //美洽客服
                MQConfig.init(getActivity(), "426d3758bf6c06e5a78398d2f84693b6", new OnInitCallback() {
                    @Override
                    public void onSuccess(String clientId) {
                        HashMap<String, String> clientInfo = new HashMap<>();
                        try {
                            clientInfo.put("name", "" + SampleApplicationLike.getUserloginInstance().getInfo().getName());
                            Intent intent = new MQIntentBuilder(getActivity())
                                    .setClientId(WecomeActivity.mqManager.getCurrentClientId() + "")
                                    .setClientInfo(clientInfo)
                                    .build();
                            startActivity(intent);
                        } catch (Exception e) {
                            clientInfo.put("name", "用户-未登录");
                        }


                        // Toasts.show(getActivity(), "init success", Toast.LENGTH_SHORT);
                    }

                    @Override
                    public void onFailure(int code, String message) {
                        Toasts.show(getActivity(), "int failure", Toast.LENGTH_SHORT);
                    }
                });
            }
        });
    }

    @Override
    protected void initEvent() {
        translucentScrollView.setListeners(new TranslucentScrollView.OnScrollChangeListeners() {
            @Override
            public void onScrollChange(int l, int t) {
                h=t;

            }
        });
        lv_jigou.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getActivity(), JGXQActivity.class);
                intent.putExtra("id", indexBeans.getData().getHotCoun().get(position).getId());
                startActivity(intent);
            }
        });
        homefragment_image_search.setOnClickListener(this);
        homefragment_image_search2.setOnClickListener(this);
        homefragment_image_message.setOnClickListener(this);
        homefragment_image_message2.setOnClickListener(this);
        tv_tese_more.setOnClickListener(this);
        tv_zx_more.setOnClickListener(this);
        tv_supei_more.setOnClickListener(this);
        tv_luyan_more.setOnClickListener(this);
        home_fragment_button_djcs_error.setOnClickListener(this);
        bangwo.setOnClickListener(this);
        tv_jg_more.setOnClickListener(this);
        /*viewFlipper.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toasts.show(context,""+viewFlipper.getDisplayedChild());
            }
        });*/
        /*初始化组件*/

        ViewGroup.LayoutParams params = v_statusbar.getLayoutParams();
        params.height = ScreenUtils.getStatusBarHeight(context);
        v_statusbar.setLayoutParams(params);
        ViewGroup.LayoutParams params2 = v_statusbar2.getLayoutParams();
        params2.height = ScreenUtils.getStatusBarHeight(context);
        v_statusbar2.setLayoutParams(params2);
        //设置透明度变化监听
        translucentScrollView.setTranslucentChangedListener(this);
        //关联需要渐变的视图
        translucentScrollView.setTransView(bar);
        //设置ActionBar键渐变颜色
        translucentScrollView.setTransColor(getResources().getColor(R.color.basecolor));
        //translucentScrollView.setPullZoomView(top_img);
        home_viewpage.post(new Runnable() {
            @Override
            public void run() {
                int n = home_viewpage.getHeight();
                int n2 =bar.getHeight();
                //关联需要渐变的视图
                translucentScrollView.setMaxHeights(n-n2);
            }
        });
        swiperefreshlayout.setColorSchemeResources(R.color.zhutise);


        swiperefreshlayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                mPresenter.getFromNet();
            }
        });
    }

    @Override
    protected void initData() {
        mPresenter.getLocal();
        getData();
    }
    private void getData(){
        swiperefreshlayout.post(new Runnable() {
            @Override
            public void run() {
                swiperefreshlayout.setRefreshing(true);
                mPresenter.getFromNet();
            }
        });
    }

    @Override
    public void onSuccess(IndexBean indexBean,boolean islocal) {
        swiperefreshlayout.setRefreshing(false);
        if (indexBean!=null){
            indexBeans = indexBean;
            showContent();
            initViews( indexBean,islocal);
        }
    }

    @Override
    public void onFail(String str) {
        swiperefreshlayout.setRefreshing(false);

    }

    @Override
    public void showErrorNet() {
        //error_ll.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideErrorNet() {
        error_ll.setVisibility(View.GONE);
    }

    @Override
    public void showContent() {
        rl_content.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideContent() {
        //rl_content.setVisibility(View.GONE);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bangwo:
                if (!SPUtils.isLogin()){
                    startActivity(new Intent(getActivity(), LoginNewActivity_two.class));
                    return;
                }
                if (SampleApplicationLike.getIndexBeanInstance()==null){
                    Toasts.show(context,"请检查网络是否连接");
                    return;
                }
                startActivity(new Intent(getActivity(), XZYWActivity.class));
                break;
            case R.id.homefragment_image_message:
            case R.id.homefragment_image_message2:
                if (SampleApplicationLike.getUserloginInstance().getId() == 0) {
                    startActivity(new Intent(getActivity(), LoginNewActivity_two.class));
                } else {
                    startActivity(new Intent(getActivity(), MessageActivity.class));
                }
            break;
            case R.id.homefragment_image_search:
            case R.id.homefragment_image_search2:
                startActivity(new Intent(getActivity(), SearchActivity.class));
                break;
            case R.id.home_fragment_button_djcs_error:
                getData();
                break;
            case R.id.tv_jg_more:
                startActivity(new Intent(getActivity(), AllJGActivity.class));

                break;
            case R.id.tv_tese_more:
                startActivity(new Intent(getActivity(), TeseActivity.class));

                break;
            case R.id.tv_luyan_more:
                ((HomeActivity)getActivity()).setSelecttool(1);
                break;
            case R.id.viewFlipper:
            case R.id.tv_zx_more:
                Intent intents = new Intent(context, FastZXActivity.class);
                startActivity(intents);
                //((HomeActivity)getActivity()).setSelecttool(0);
                break;
            case R.id.tv_supei_more:
                startActivity(new Intent(getActivity(), SuPeiActivity.class));
                break;
        }
    }

    @Override
    public void onTranslucentChanged(int transAlpha) {
        bar_title.setVisibility(transAlpha > 100 ? View.VISIBLE : View.GONE);
    }

    public static boolean isHaveMessage = false;
    @Override
    public void onResume() {
        super.onResume();
        if (h>0){
            QTLog.e(h);
            translucentScrollView.smoothScrollTo(0,h);
        }
        isHaveMessage = SPUtils.isShowMsg();
        if (isHaveMessage){
            homefragment_image_message.setImageResource(R.drawable.xxtz_yes);
            homefragment_image_message2.setImageResource(R.drawable.xxtz_yes);
        }else {
            homefragment_image_message.setImageResource(R.drawable.xxtz_no);
            homefragment_image_message2.setImageResource(R.drawable.xxtz_no);
        }

    }

    public void showMsg() {
        homefragment_image_message.setImageResource(R.drawable.xxtz_yes);
        homefragment_image_message2.setImageResource(R.drawable.xxtz_yes);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        isLoad = false;

    }

    /**
     * 初始化轮播图
     */
    private void initViewPage(final IndexBean indexBean) {
        List mList = new ArrayList();
        for (IndexBean.DataBean.BannerBean url_image : indexBean.getData().getBanner()) {
            mList.add(url_image.getImage());
        }
        // mList = indexBean.getData().getBanner();
        home_viewpage.setPages(new CBViewHolderCreator<ImageViewHodler>() {
            @Override
            public ImageViewHodler createHolder() {
                return new ImageViewHodler();
            }
        }, mList).setPageIndicator(new int[]{R.mipmap.top_unchoose_new, R.mipmap.top_choose}) //设置两个点作为指示器
                .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.CENTER_HORIZONTAL);//设置指示器的方向水平  居中;
        home_viewpage.startTurning(3000);
        home_viewpage.setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT);
        home_viewpage.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                // Toasts.show(context, "posit
                //
                // on", Toast.LENGTH_SHORT);

                if(!TextUtils.isEmpty(indexBean.getData().getBanner().get(position).getUrl())){
                    Intent intent = new Intent(getActivity(),BannerActivity.class);
                    intent.putExtra("url",indexBean.getData().getBanner().get(position).getUrl());
                    intent.putExtra("title",indexBean.getData().getBanner().get(position).getTitle());
                    startActivity(intent);
                }


                else if (position == 2){
                    HomeActivity parentActivity = (HomeActivity) getActivity();
                    parentActivity.chooseTab(1);
                }else if (position == 0){

                }else if (position == 1){
                    Toasts.show(context, "等待ui图", Toast.LENGTH_SHORT);
                }


            }
        });
    }

    /**
     * 初始化首页便签分类
     */

    private void initmGridViewPager(final IndexBean indexBean) {
        mGridViewPager
                //设置每一页的容量
                .setPageSize(8)
                .setGridItemClickListener(new GridItemClickListener() {
                    @Override
                    public void click(int pos, int position, String str) {
                        try {

                            List<IndexBean.DataBean.BusinessBean> businessBeen_list = indexBean.getData().getBusiness();

                            //startActivity(new Intent(getActivity(), LoginNewActivity.class));
                            //Toasts.show(mActivity, "" + str, Toast.LENGTH_SHORT);

                            if (businessBeen_list.get(position).getType() == 2 && businessBeen_list.get(position).getGenre() == 0) {
                                Intent intent = new Intent(getActivity(), SearchYWActivity_new.class);
                                intent.putExtra("id", businessBeen_list.get(position).getId());
                                intent.putExtra("title", str);
                                startActivity(intent);
                                //startActivity(new Intent(getActivity(),TestEditActivity.class));
                            }

                            else if (businessBeen_list.get(position).getType() == 1 && businessBeen_list.get(position).getGenre() == 0) {
                                Intent intent = new Intent(getActivity(), SQXMActivity.class);
                                intent.putExtra("id", businessBeen_list.get(position).getId());
                                //intent.putExtra("title", str);
                                startActivity(intent);
                            }
                            else if(businessBeen_list.get(position).getGenre() == 1){
                                Intent intent = new Intent(getActivity(), BGZRSearch_new.class);
                                intent.putExtra("id", businessBeen_list.get(position).getId());
                                //QTLog.e("并购转让"+businessBeen_list.get(position).getId());
                                startActivity(intent);
                            }
                        }catch (Exception e){

                        }
                    }
                })

                //传入String的List 必须作为最后一步
                .init(initDatas(indexBean));
    }


    /**
     * 作为测试的数据初始化
     *
     * @return
     */
    private List<Model> initDatas(IndexBean indexBean) {
        List mData = new ArrayList();
        try{
            for (int i = 0; i < indexBean.getData().getBusiness().size(); i++) {
                String imageId = indexBean.getData().getBusiness().get(i).getImg();
                String name = indexBean.getData().getBusiness().get(i).getTitle();
                mData.add(new Model(name, imageId));
            }
            return mData;
        }catch (Exception e){

        }
        return mData;
    }
    private void initViews(IndexBean indexBean,boolean islocal){
        initViewPage(indexBean);
        initmGridViewPager(indexBean);
        if (!islocal){
            initJGListView(indexBean);
        }

        //initZXView(indexBean);
        /*initLuyanListView(indexBean);
        initTeseListView(indexBean);
        initSupeiView(indexBean);*/
        translucentScrollView.smoothScrollTo(0,0);
    }

    @Override
    public void showSuPei(List list) {
        initSupeiView(list);
    }

    @Override
    public void showService(List list) {
        initTeseListView(list);
    }

    @Override
    public void showLuyan(List list) {
        initLuyanListView(list);
    }

    private void initLuyanListView(final List list){
        lv_luyan.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(context, LuYanDeatilActivity.class);

                intent.putExtra("id",((LuYanList)list.get(position)).getId());
                startActivity(intent);
            }
        });
        lv_luyan.setAdapter(new LuYanadapter(context,list));
    }
    private void initTeseListView(final List list){
        lv_tese.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(context, TeseDeatils.class);

                intent.putExtra("id",((SeriveList)list.get(position)).getId());
                startActivity(intent);
            }
        });
        lv_tese.setAdapter(new Teseadapter(context,list));
    }
    private int h=0;
    @Override
    public void onPause() {
        super.onPause();
        //h = translucentScrollView.getTop();
    }



    private void initrecyclerView(){
        recyclerView.setOrientation(Orientation.HORIZONTAL);
        recyclerView.setItemTransitionTimeMillis(150);
        recyclerView.setItemTransformer(new ScaleTransformer.Builder()
                .setMinScale(0.8f)

                .build());
         /*设置点击ViewPager之外的部位，ViewPager跟着滑动*/
        ViewGroup parent = (ViewGroup) recyclerView.getParent();
        parent.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return recyclerView.dispatchTouchEvent(event);
            }
        });
        //recyclerView.scrollToPosition();
        recyclerView.addOnItemChangedListener(new DiscreteScrollView.OnItemChangedListener<RecyclerView.ViewHolder>() {
            @Override
            public void onCurrentItemChanged(@Nullable RecyclerView.ViewHolder viewHolder, int adapterPosition) {
                int positionInDataSet = infiniteAdapter.getRealPosition(adapterPosition);
                QTLog.e(positionInDataSet);
                if (recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE
                        && !recyclerView.isComputingLayout()&&shopAdapter!=null){
                    //shopAdapter.setSelect(positionInDataSet);
                }
            }
        });
    }
    GalleryAdapter recyclerAdapter;
    InfiniteScrollAdapter infiniteAdapter;
    ShopAdapter shopAdapter;
    List lists = new ArrayList();
    private void initSupeiView(List listtmp){
        lists.clear();
        for (int i=0;i<listtmp.size();i++){
            lists.add(listtmp.get(i));
        }

        if (recyclerAdapter==null){
            shopAdapter = new ShopAdapter(lists,context);
            shopAdapter.setOnItemClickListener(new ShopAdapter.OnItemClickListener() {
                @Override
                public void onItemClick(int pos) {
                    if (infiniteAdapter.getRealCurrentPosition()==pos){
                        Intent intent = new Intent(context,SuPeiDeatilActivity.class);
                        intent.putExtra("id",((Supeis)lists.get(pos)).getId());
                        startActivity(intent);
                    }

                }
            });


            infiniteAdapter = InfiniteScrollAdapter.wrap(shopAdapter);
            recyclerView.setAdapter(infiniteAdapter);
            /*recyclerAdapter = new GalleryAdapter(context,lists);
            *//*recyclerAdapter.setListener(new SupeiAdapter.OnItemClickListener() {
                @Override
                public void onItemClick(int pos) {
                    galleryLayoutManager.smoothScrollToPosition(recyclerView, null, pos);
                    Intent intent = new Intent(context,SuPeiDeatilActivity.class);
                    startActivity(intent);
                }
            });*//*
            recyclerView.setAdapter(recyclerAdapter);*/
        }else {
            infiniteAdapter.notifyDataSetChanged();
        }

        //lv_luyan.setAdapter(new LuYanadapter(context,indexBean.getData().getBanner()));
    }

    private void initJGListView(IndexBean indexBean){
        lv_jigou.setAdapter(new JGadapter(context,indexBean.getData().getHotCoun()));
    }

    @Override
    public void showZX(TmpZxBean zxBean) {
        viewFlipper.removeAllViews();
        //测试
        List<TmpZxBean.ListBean> list = zxBean.getList();
        if (list.size()>=0){
            if (list.size()==1){
                //如果只有一个，再添加一个
                list.add(list.get(0));
            }
            for (int i=0;i<list.size();i++){
                View view = View.inflate(context, R.layout.item_home_zx, null);
                TextView tv_times = view.findViewById(R.id.tv_time);
                TextView tv_contents = view.findViewById(R.id.tv_content);
                tv_contents.setText(list.get(i).getContent());
                String t = Contants.getTimes(list.get(i).getTime());
                tv_times.setText(t);
                viewFlipper.addView(view);
            }

        }
    }

}
